package com.googlecode.mailnet.emf.netmodel.visualization.failure;

import org.eclipse.draw2d.Graphics;
import org.eclipse.draw2d.Shape;
import org.eclipse.swt.graphics.Color;

import com.googlecode.mailnet.emf.netmodel.visualization.ShapeDecorator;
import com.googlecode.mailnet.info.INodeInfo;

public class FailureNodeDecorator extends ShapeDecorator {
	
	INodeInfo nodeInfo;
	Color okColor = new Color(null, 0, 255, 0);
	Color failureColor = new Color(null, 255, 0, 0);
	
	public FailureNodeDecorator(INodeInfo nodeInfo) {
		this.nodeInfo = nodeInfo;
	}
	
	public boolean outlineShape(Shape shape, Graphics g) {
		shape.setForegroundColor(nodeInfo.isBroken() ? failureColor : okColor);
		shape.setLineStyle(nodeInfo.isBroken() ? Graphics.LINE_DASH : Graphics.LINE_SOLID);
		return false;
	}
	
	public boolean fillShape(Shape shape, Graphics g) {
		shape.setBackgroundColor(nodeInfo.isBroken() ? failureColor : okColor);
		return false;
	}

}
